package thread;

/**
 * @author: 成金乘
 * @date: 2022/11/29 11:30
 * @description:
 */
//继承 Thread, 重写 run
class MyThread extends Thread{
    @Override
    public void run() {
        while(true){
            System.out.println("hello word");
            try {
                Thread.sleep(1000);
            }catch (InterruptedException e){
                e.printStackTrace();
            }
        }
    }
}
public class ThreadDemo1 {
    public static void main(String[] args){
        Thread t = new MyThread();
        t.start();//启动线程需要调用start方法
        while(true){
            System.out.println("hello main");
            try {
                Thread.sleep(1000);
            }catch (InterruptedException e){
                e.printStackTrace();
            }
        }

    }

}
